package com.example.tianyidemo.controller;

import com.example.tianyidemo.pojo.DeleteRequest;
import com.example.tianyidemo.pojo.Result;
import com.example.tianyidemo.service.DelpostService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@CrossOrigin//准许跨域请求
@RestController//包含@Controller（三层架构声明控制器）和@ResponseBody（转化json格式）
public class DelpostController {
    @Autowired
    private DelpostService delpostService;
    @DeleteMapping("/deletepost")
    public Result deletePost(@RequestBody DeleteRequest request) {
        String uniqueStr = request.getUniqueStr();
        System.out.println(uniqueStr);
        boolean isSuccess =delpostService.deletepost(uniqueStr);
        if (isSuccess) {
            return Result.success("房源删除成功");
        } else {
            return Result.error("房源删除失败");
        }
    }


}
